<%@language=vbscript%>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<%
	select case Session("FormName")
		case "F19"
			Session("bChucnang")=9
		case "F20"
			Session("bChucnang")=8
		case "F21"
			Session("bChucnang")=8
		case "F23"
			Session("bChucnang")=5
	end select 
%>
<!--#include file="..\CheckSession.inc"-->
<%	bstepduyet=request("bstepduyet")+1
	bCommDuyetCB=Request("bCommDuyetCB")
	bMaLoaiVT=request("bMaLoaiVT")
	bMavanthu=request("MaVT")
	bCheck=Request("RChon")
	if bCommDuyetCB<>"" and request("bok")="ok" then
		Max=Request("TotalMax")
		if max="" then max=0
		for i=1 to Max
			R="CheckR"+cstr(i)
			bcheckR=request(R)
'			if bcheck<>"" then
				ten="Ma"+cstr(i)
				bMaCB=request(ten)
				'bMaVT=request("MaVT")
				if bCommDuyetCB="update" then
					sSQL="Delete from Quyen Where macanbo like '"& bMaCB &"' and Mavanthu Like '"& bMavanthu &"' and MaLoaiVanThu Like '"& bMaLoaiVT &"'"						
					Conn.Execute sSQL

					if bCheckR<>"" then
						sSQL="Insert into Quyen(macanbo,quyen,mavanthu,maloaivanthu) values('"& bMaCB &"','R','"& bMavanthu &"','"& bMaLoaiVT &"')"
						Conn.Execute sSQL
					end if
				end if
		next
		bCommDuyetCB="update"
	end if	
%>	
<%	
	Dim TotalN
	Set Rec=server.CreateObject("ADODB.Recordset") 
	rec.CursorType = 3
	rec.CacheSize=5
	bMaVT=Request("MaVT")
	
	dieukien=""
	if Request("tim")="ok" then		
		dieukien="WHERE hovaten like '%"& Request("TxtS") &"%' "
	end if

	sSQL="SELECT Macanbo, Hovaten,(select DISTINCT(Quyen.quyen) from quyen where Canbo.Macanbo = Quyen.Macanbo and Quyen.maloaivanthu Like '"& bMaLoaiVT &"' and Quyen.mavanthu Like '"& bMaVT &"' ) quyen FROM Canbo " & dieukien &" order by stt1,stt2,stt3, ten, hovaten"

	bCommDuyetCB="update"
	rec.Open ssql,Conn
%>
<title>M&#7853;t kh&#7849;u duy&#7879;t</title>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--

function CheckallR_onclick() {
	<%for i=1 to Rec.recordcount%>
		if (frm.CheckallR.checked ){
			frm.CheckR<%=i%>.checked=true;
		}
		else{
			frm.CheckR<%=i%>.checked=false;
		}
	<%next%>	
}

function CheckallF_onclick() {
	<%for i=1 to Rec.recordcount%>
		if (frm.CheckallF.checked ){
			frm.CheckF<%=i%>.checked=true;
		}
		else{
			frm.CheckF<%=i%>.checked=false;
		}
	<%next%>	
}

function CheckallW_onclick() {
	<%for i=1 to Rec.recordcount%>
		if (frm.CheckallW.checked ){
			frm.CheckW<%=i%>.checked=true;
		}
		else{
			frm.CheckW<%=i%>.checked=false;
		}
	<%next%>	
}
function Rowcheck(i){
//	if (frm.CheckF.checked){
//		frm.CheckR.checked=true;
//		frm.CheckW.checked=true;
//	}	
}
function CmdDuyet_onclick() {
	<%if bCommDuyetCB="update" then%>
		window.frm.action="duyetcanbo.asp?bstepduyet="+<%=bstepduyet%>+"&bok=ok&bCommDuyetCB=update&MaVT="+"<%=bMaVT%>"+"&bMaLoaiVT="+"<%=bMaLoaiVT%>"
	<%else%>
		window.frm.action="duyetcanbo.asp?bstepduyet="+<%=bstepduyet%>+"&bok=ok&bCommDuyetCB=new&MaVT="+"<%=bMaVT%>"+"&bMaLoaiVT="+"<%=bMaLoaiVT%>"
	<%end if%>
	window.frm.submit();
}

function CmdExit_onclick() {
	window.history.go(-<%=bstepduyet%>);
}

function R1_onclick() {
	frm.target="right";
	frm.action="duyetcanbo.asp?MaVT=<%=bMavanthu%>&bMaLoaiVT=<%=bMaLoaiVT%>&bstepduyet=<%=bstepduyet%>";
	frm.submit();
}

function R2_onclick() {
	frm.target="right";
	frm.action="duyetnhom.asp?MaVT=<%=bMavanthu%>&bMaLoaiVT=<%=bMaLoaiVT%>&bstepduyet=<%=bstepduyet%>";
	frm.submit();
}

//-->
</SCRIPT>
</head>
<body leftmargin=2 topmargin=2 bgcolor=#F8F9D9 style="font-family:Times New Roman">
<form name=find method=post action="duyetcanbo.asp?tim=ok&bstepduyet=<%=bstepduyet%>&bMaLoaiVT=<%=bMaLoaiVT%>&MaVT=<%=bMavanthu%>&RChon=user">
	<table  border="0" width=100%>
		<tr>
			<td width=20% nowrap align=center>Tìm theo tên</td>
			<td width=60%>
            <input name=TxtS style="font-family:Arial;width:100%" size="20"></td>
			<td width=20%><input name=CmdS value="Tìm kiếm" type=submit style="font-family:Arial;width:100%"></td>
		</tr>
	</table>
</form>
<form name=frm method=POST>
<table border="0" width="100%" cellspacing=1 cellpadding=0>
    <tr>
      <td width="50%" align=right><input type="button" value="Ghi nhận" name="CmdDuyet" style="font-family: Arial; center: 0px; position: relative; width:80; height: 23" LANGUAGE=javascript onclick="return CmdDuyet_onclick()"></td>
      <td width="50%" align="left"><input type="button" value="Quay lại" name="CmdExit" style="font-family: Arial; center: 0px; position: relative; width:80; height:23"  LANGUAGE=javascript onclick="return CmdExit_onclick()"></td>
    </tr>
    <tr>
		<td width="100%" align=center colspan="2">
			<%if bCheck="user" then%>
				<label for=R1>Danh s&#225;ch c&#225;n b&#7897;</label><input ID=R1 checked type="Radio" value="user" name=RChon LANGUAGE=javascript onclick="return R1_onclick()">
			<%else%>
				<%if bstepduyet=1 then%>
				<label for=R1>Danh s&#225;ch c&#225;n b&#7897;</label><input ID=R1 checked type="Radio" value="user" name=RChon LANGUAGE=javascript onclick="return R1_onclick()">
				<%else%>
				<label for=R1>Danh s&#225;ch c&#225;n b&#7897;</label><input ID=R1 type="Radio" value="user" name=RChon LANGUAGE=javascript onclick="return R1_onclick()">
				<%end if%>
			<%end if%>
			<%if bCheck="group" then%>
				<input type="Radio" ID=R2 checked value="group" name=RChon LANGUAGE=javascript onclick="return R2_onclick()"><label for=R2>Danh s&#225;ch nh&#243;m</label>
			<%else%>
				<input type="Radio" ID=R2 value="group" name=RChon LANGUAGE=javascript onclick="return R2_onclick()"><label for=R2>Danh s&#225;ch nh&#243;m</label>
			<%end if%>
		</td>
    </tr>
</table>
<table border="0" width="100%" style="font-size:13;font-family:arial;border-style: solid;border-color:#C0C0C0">
    <tr>
      <td width="100%" colspan="2" bgcolor="#173584" ALIGN="CENTER"><b>
      <font face="Arial" color="#FFFFFF">QUYỀN CÁN BỘ ĐỐI VỚI CÔNG VĂN</font></b></td>
    </tr>
    <tr>      
      <td width="5%" bgcolor="#bdd5d0" align="center"><input type="checkbox" name="CheckallR" value="ON" LANGUAGE=javascript onclick="return CheckallR_onclick()"></td>
      <td width="95%" bgcolor="#bdd5d0" align="center"><font face="Arial">T&#234;n c&#225;n b&#7897;</font></td>
	  </tr>
<%	
	If Not Rec.EOF Then
		nRecCount = Rec.RecordCount
		Rec.PageSize = 20
		nPageCount = Rec.PageCount
		If nPage < 1 then
			nPage = 1			
		End If
		if nPage > nPageCount Then
			nPage=nPageCount
		end if
		TotalN=rec.recordcount
		%>
		<input type="hidden" name=TotalMax value=<%=TotalN%>>
	<%
		STT=1
		rec.AbsolutePage=nPage
		cnt=1
		do while not Rec.EOF
			if (cnt/2=int(cnt/2)) then
				color="#eeeecc"
			else
				color="#F8F9D9"
			end if
%>
		<tr bgcolor=<%=color%>>      		
			<%if Rec("quyen")<>"" then%>
      			<td width="5%" height="1" align="center">
                    <input type="checkbox" name=CheckR<%=STT%> Checked value="ON">
        		</td>
        	<%	else%>
        	     <td width="5%" height="1" align="center">
                    <input type="checkbox" name=CheckR<%=STT%> value="ON" >
   				</td>
   			<%	end if%>

			<%	
					Dim bDisabled  
					bDisabled=FALSE
					select case Session("FormName")
					case "F19"
						if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),9)<>"1" and not Session("IsAdmin") then 
							bDisabled=TRUE
						end if
					case "F20"
						if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),8)<>"1" and not Session("IsAdmin") then 
							bDisabled=TRUE
						end if
					case "F21"
						if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),8)<>"1" and not Session("IsAdmin") then 
							bDisabled=TRUE
						end if
					case "F23"
						if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),5)<>"1" and not Session("IsAdmin") then 
							bDisabled=TRUE
						end if
					end select 
			%>
        	<% if bDisabled then %>
				<td width="5%" height="1" bgcolor="#bdd5d0" align="center">
					<input type="checkbox" name=CheckR<%=STT%> disabled=true value="ON">
				</td>
        	<%end if%>
        	<td width="95%" height="1"><font face="Arial"><%=rec("hovaten")%></font><input type="hidden" name=Ma<%=STT%> value=<%=Rec("Macanbo")%>></td>      				
		</tr>
<%			STT=STT+1
			Rec.MoveNext
			cnt=cnt+1
		loop
	end if
	rec.Close
	set rec=nothing
%>  			
</table>
</form>
</body>
</html>
<%
	Conn.Close
	set Conn=nothing
%>